#ifndef _LINKTREE_H_
#define _LINKTREE_H_

#include "DoubleLinkList.h"
#define TreeElementType char*

//树节点
struct TreeNode;
typedef struct TreeNode TNode;

//创建树节点
TNode *CreateTreeNode(TreeElementType element);
//销毁树节点
void FreeTreeNode(void *n);
void ClearLinkTree(void* tree);
//获取节点数据域
void* GetTreeNodeData(TNode *node);


//链接分支
void ConnectBranch(TNode * parent, TNode * child);
//断开分支
void DisconnectBranch(TNode *parent, TNode *child);
//遍历节点
void TravelTreeNode(TNode *node,int deepth, void (*funcPtr)(void*));
//查找某个节点的某个孩子
TNode * FindChildNode(TNode *parent, void *value, bool(*funcPtr)(void *,void*));

struct LinkTree;
typedef struct LinkTree LTree;

LTree* InitLinkTree();
TNode * GetTreeRoot(LTree *tree);
//打印树
void TravelTree(LTree *tree, void(*funcPtr)(void*));
//获取树的高度
int GetTreeHeight(LTree *tree);
//查找结点
TNode *FindLinkTreeNode(LTree *tree, void *value, bool (*funcPtr)(void*,void*));

//找到所有的叶子节点
DLlist FindAllLeafBranches(LTree *tree);

#endif